import {API,header} from 'config/config.js'
async function Login(){
	var code= await uni.login({
	  provider: 'weixin'
	})
	var token= await uni.request({
	    url: `${API}/wx/code`,
		method:"POST",
	    data: {
	        code:code[1].code
	    },
		header:{
			"Content-Type":"application/x-www-form-urlencoded"
		}
	})
	console.log(token)
	console.log(11)
	header.Authorization=token[1].data.data.token
	uni.setStorageSync('token',token[1].data.data.token)
	uni.setStorageSync("role",token[1].data.data.role)
	uni.setStorageSync("express_id",token[1].data.data.express_id)
	return token[1].data.data.token
}
/* 
function Login() {
	let url = "http://kk.y-li.com/wx/auth";
	let token =getToken();
	console.log(token);
	if (!token) {
		window.location.href = url;
	}else {
		uni.setStorageSync("token",token);
	}
}

function getToken(url) {
	console.log(location)
	return location.search.split("=")[1];
} */

export {
	Login
}